﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class HeDan : MonoBehaviour {

	//发射间隔
	float m_timer = 0;
	GameManager game;
	void Start () {
	
		Button btn = gameObject.GetComponent<Button>();
		btn.onClick.AddListener(fashe);
		game = GameObject.FindGameObjectWithTag("GameObject").gameObject.GetComponent<GameManager>();
	}

	void Update () {
	    
		m_timer-=Time.deltaTime;
		if(m_timer<=0)
		{
			m_timer=0;
		}
	}

	public void fashe()
	{
		if(Input.GetKey(KeyCode.Space))
		{

		}else{
			if(m_timer<=0)
			{
				if(game.hedan_number >= 1)
				{
		           Instantiate(Resources.Load<GameObject>(SampleXml.prefabPath[20].ToString()));
					game.zuanshi_state(1);
			       m_timer =7;
				}
			}
		}

	}
}
